package com.example.shaidemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.SpannableString;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ConfigPersonalActivity extends AppCompatActivity implements View.OnClickListener {

    private static final String TAG = "ConfigPersonalActivity";
    EditText editName;
    TextView editAccount;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config_personal);

        //获取传递过来的个人信息;
        Intent mes = getIntent();
        String oldName = mes.getStringExtra("name");
        String account = mes.getStringExtra("account");
        Log.i(TAG, "onCreate: name = "+oldName+"   account == "+account);

        editName = findViewById(R.id.editName);
        editAccount = findViewById(R.id.editPhone);
        editAccount.setText(account);
        //设置EditText中Hint的文本内容
        SpannableString str = new SpannableString(oldName);
        editName.setHint(str);
    }

    @Override
    public void onClick(View view) {
        String name  = editName.getText().toString().trim();
        Intent intent = new Intent(ConfigPersonalActivity.this,MainActivity.class);
        intent.putExtra("newName",name);
        setResult(2, intent);;
        finish();
    }
}